using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Documents;
namespace Orbifold.Trefoil
{
    /// <summary>
    /// Keeps track of the selected shape(s).
    /// </summary>
    static class SelectionManager
    {
        #region Fields
      
        private static RichTextBox mRTB;

        private static TextRange mSelectedText;
        #endregion

        #region Properties

        public static TextRange SelectedText
        {
            get { return mRTB.Selection; }
            set { mRTB.Selection.Select(value.Start, value.End); }
        }

        public static RichTextBox TextEditor
        {
            get { return mRTB; }
            set { mRTB = value; }
        }
        #endregion

        #region Constructor
        static SelectionManager()
        {
            
        }
        #endregion

        #region Methods
       
        public static void UnselectAll()
        {
            mRTB.Selection.Select(mRTB.Selection.Start,mRTB.Selection.Start);

        }
       
        #region Adornmental methods
        private static void AddAdorner(UIElement rec)
        {
            
            //adornerLayer = AdornerLayer.GetAdornerLayer(rec);
            //System.Diagnostics.Debug.Assert(adornerLayer != null, "Oops, you have not defined an AdornerDecorator in the template, check the generic.xaml file.");
            //if (adornerLayer == null)
            //    return;
            //if ( adornerLayer.GetAdorners(rec) == null)
            //{
            //    ResizingAdorner rad = new ResizingAdorner(rec);

            //    if (rec is Connectable)
            //    {
            //        rad.HeightEnabled = (rec as Connectable).ResizableHeight;
            //        rad.WidthEnabled = (rec as Connectable).ResizableWidth;
            //        rad.MinHeight = (rec as Connectable).MinHeight;
            //        rad.MinWidth = (rec as Connectable).MinWidth;
            //    }

            //    adornerLayer.Add(rad);
            //}

        }

        private static void RemoveAdorner(UIElement rec)
        {
            //adornerLayer = AdornerLayer.GetAdornerLayer(rec);
            //System.Diagnostics.Debug.Assert(adornerLayer != null, "Oops, you have not defined an AdornerDecorator in the template, check the generic.xaml file.");
            //if (adornerLayer!=null && adornerLayer.GetAdorners(rec) != null)
            //    adornerLayer.Remove(adornerLayer.GetAdorners(rec)[0]);
        }
        #endregion

        #endregion
    }
}
